package lab.southpark.demo.tests.user
{
    import com.southpark.demo.view.pages.welcome.WelcomePageCtrl;
    import com.southpark.demo.view.pages.welcome.interfaces.IWelcomePageCtrl;
    
    import flash.events.TimerEvent;
    
    import lab.southpark.demo.tests.BaseTestCase;
    
    
    
    public class UserSessionTestCase extends BaseTestCase
    {
        
        public function testUserLogin():void
        {
		    var welcomePageCtrl:IWelcomePageCtrl = new WelcomePageCtrl(new FakeWelcomePageUI());
		    welcomePageCtrl.userLogin("test","test",false);
		    
		    waitToTest(onTestUserLogin,1000);
		}
		
		private function onTestUserLogin(timerEvent:TimerEvent):void
        {
        	assertNotNull("Expecting sessionId",model.sessionId);
        }
        
        
        
        
        public function testUserLoginWithWrongPassword():void
        {
		    var welcomePageCtrl:IWelcomePageCtrl = new WelcomePageCtrl(new FakeWelcomePageUI());
		    welcomePageCtrl.userLogin("test","",false);
		    
		    waitToTest(onTestUserLoginWithWrongPassword,1000);
		}
		
		private function onTestUserLoginWithWrongPassword(timerEvent:TimerEvent):void
        {
        	assertNull("Expecting empty sessionId",model.sessionId);
        }
        
       
		
    }
}
	

// fake UIs
{	
	import com.southpark.demo.view.pages.welcome.interfaces.IWelcomePageUI;
	
	class FakeWelcomePageUI implements IWelcomePageUI
	{
		public function resetFocus():void {}
	}
	
}


